package com.springboot.mapper;

import java.math.BigDecimal;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.springboot.po.User;

@Mapper
public interface UserMapper {
	//返回行数代表是否注册
	@Select("select count(*) from user where userId = #{userId}")
	public int getUserById(String userId);
	
	@Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},null,1 ,0 ,0 ,0)")
	public int saveUser(User user);
	
	@Select("select * from user where userId=#{userId} and password=#{password}")
	public User getUserByIdByPass(User user);
	
	@Select("select * from user where userId=#{userId}")
	public User findSerect(User user);
	
	@Select("select points from user where userId=#{userId}")
	public BigDecimal getPoints(String userId);
	
	@Select("select maxPoints from user where userId=#{userId}")
	public BigDecimal getMaxPoints(String userId);
	
	@Select("select memLevel from user where userId=#{userId}")
	public int getMemLevel(String userId);
	
	@Update("update user set points = #{points} where userId = #{userId}")
	public int updatePoints(String userId , BigDecimal points);
	
	@Update("update user set maxPoints = #{maxPoints} where userId = #{userId}")
	public int updateMaxPoints(String userId , BigDecimal maxPoints);
	
	@Update("update user set memLevel = #{memLevel} where userId=#{userId}")
	public int updateMemLevel(String userId , int memLevel);
}
